﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace Cherry.Agile.UI.Framework
{
    /// <summary>
    /// 定义Web端的上下问信息
    /// </summary>
    public sealed class ApplicationContext
    {
        public static readonly int InstanseId;
        static ApplicationContext()
        {
            Mode = Cherry.Agile.Configuration.AgileConfiguration.Current.ApplicationSection.Mode;
            Version = Assembly.GetExecutingAssembly().GetName().Version;
            Multiple = Cherry.Agile.Configuration.AgileConfiguration.Current.ApplicationSection.Multiple;
            var id = DateTime.Now.GetHashCode();
            if (id < 0)
                id = 0 - id;
            InstanseId = id;
        }

        /// <summary>
        /// 安装模式
        /// </summary>
        public static string Mode { get; private set; }

        /// <summary>
        /// 
        /// </summary>
        public static bool Multiple { get; private set; }

        /// <summary>
        /// 版本
        /// </summary>
        public static Version Version { get; private set; }

        /// <summary>
        /// 资源路径
        /// </summary>
        public static string ResouceUrlRoot { get; set; }

        /// <summary>
        /// 是否是VIP模式
        /// </summary>
        /// <returns></returns>
        static bool IsVIP()
        {
            return string.IsNullOrEmpty(Mode) || string.Compare(Mode, "VIP", true) == 0;
        }

    }
}
